package main

import (
	"fmt"
	"strconv"
	"time"
)

<<<<<<< HEAD
// for循环的坑 -> 指针
=======
>>>>>>> origin/dev
func main() {
	//var out []*int
	//for 循环的临时变量会复用
	//for i := 0; i < 3; i++ {
	//	tmp := i
	//	out = append(out, &tmp)
	//}
	//for _, value := range out {
	//	fmt.Println(*value)
	//}
	//假设我又一批商品id，我现在想要拿到这批商品id的详情，并发启动多个goroutine去拿这批商品的详情
	goodsID := []uint64{1, 2, 3, 4, 5}
	for _, id := range goodsID {
		//tmp := id
		//值传递
		go func(id uint64) {
			fmt.Println("正在查询商品：" + strconv.Itoa(int(id)))
		}(id)
	}
	time.Sleep(time.Second * 5)
}
